use std::num::ParseIntError;

type RESULT<I> = Result<I, ParseIntError>;

fn main() {
    println!("Hello, world!");
    p(m("10", "2"));
    p(m("20", "a"));
}

fn p(r: RESULT<i32>) {
    match r {
        Ok(n) => println!("n is {}", n),
        Err(e) => println!("error: {}", e),
    }
}

fn m(f_str: &str, s_str: &str) -> RESULT<i32> {
    let f = f_str.parse::<i32>()?;
    let s = s_str.parse::<i32>()?;
    Ok(f * s)
}
